﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Cosmetic.Logic;

namespace WebApp.Controls
{
    public partial class AttentionProduct : System.Web.UI.UserControl
    {
        private ProductManager m_ProductManager = new ProductManager();
        private FocusManager theFocusManager = new FocusManager();
        int count = 0;
        int showcount;

        public int ShowCount
        {
            get { return showcount; }
            set { showcount = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            count = 1;
            this.BindProduct();
            BindImage();
        }



        private void BindProduct()
        {
            this.lvProduct.DataSource = m_ProductManager.GetCurrentMonthSalesProductInfo(showcount);
            this.lvProduct.DataBind();

            this.ListView1.DataSource = m_ProductManager.GetCurrentWeeklySalesProductInfo(showcount);
            this.ListView1.DataBind();


            //this.ListView2.DataSource = this.m_ProductManager.GetFocusProductInfo(9).ToList();
            this.ListView2.DataSource = theFocusManager.GetFocusProduct();
            this.ListView2.DataBind();
            
        }
        protected void lvProduct_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            Label lll = (e.Item.FindControl("lbName") as Label);
            if (lll.Text.Length > 18)
            {
                lll.Text = lll.Text.Substring(0, 18);
            }
        }

        public void BindImage()
        {
            //this.Image1.ImageUrl = m_ProductManager.GetMonthlySaleImage().PicUrl;
            //this.HyperLink1.NavigateUrl = "~/Product/ProductInfo.aspx?PID=" + m_ProductManager.GetMonthlySaleImage().ProductId;
            //this.Image2.ImageUrl = m_ProductManager.GetWeeklySaleImage().PicUrl;
            //this.HyperLink3.NavigateUrl = "~/Product/ProductInfo.aspx?PID=" + m_ProductManager.GetWeeklySaleImage().ProductId;
        }
    }
}